#include <iostream>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include "1.h"

namespace ModernCpp11_1
{
    // 保证稳定与兼容
namespace Md_1_1
{


void TestSameDefine()
{
    std::cout << __STDC_HOSTED__ << "\n";
    std::cout << __STDC__ << "\n";
    
    #ifdef __STDC_VERSION__
    std::cout << __STDC_VERSION__ << "\n";
    #endif

    std::cout << __STDC_ISO_10646__ << "\n";


    std::cout << __func__ << "\n";

}

#define LOG(...)    {\
    fprintf(stderr, "%s Line %d\t", __FILE__, __LINE__); \
    fprintf(stderr, __VA_ARGS__);   \
    fprintf(stderr, "\n");  \
}

void TestVarArgs()
{
    LOG("test");
}

}

namespace Md_1_2
{


void TestLongLong()
{
    long long ll_min = LLONG_MIN;
    long long ll_max = LLONG_MAX;

    unsigned long long ull_max = ULLONG_MAX;

    printf("min long long :%lld\n", ll_min);
    printf("max long long :%lld\n", ll_max);
    printf("max unsigned long long :%llu\n", ull_max);
}



} // namespace Md_1_2


namespace Md_1_4
{
void TestCplusplus()
{
    std::cout << __cplusplus << "\n";
}
}


namespace Md_1_5
{

char* ArrayAlloc(size_t n)
{
    assert(n > 0);
    return new char[n];
}

template<typename T, typename U>
int bit_copy(T& a, U& b)
{
    static_assert(sizeof(a) == sizeof(b), "no bit copy");
    memccpy(&a, &b, sizeof(a));
    return 1;
}

void TestAssert()
{

    //    ArrayAlloc(0);

    int a = 1;
    double b = 2.0;
    bit_copy(a, b);
}


}
    
}



